<?php 
session_cache_expire(999999999);
if(!isset($_SESSION)) 
{ 
	session_start(); 
}
$lang = $_SESSION['lang'];
if (empty($lang) || $lang == "EN") {
	include "../value/value_en.php";
} else if($lang == "VN") {
	include "../value/value_vn.php";
}
else {
	include "../value/value_kr.php";
}
include '../operations/connection.php';	


$_SESSION['groupAssets2']=$_REQUEST['id'];
$assets=mysql_query("SELECT a.*,t.name as nametype,e.FullName FROM assets a, type_assets t,employee e WHERE a.`group` =".$_REQUEST['id']." AND a.type=t.id AND a.creater=e.IDEmployee ORDER BY t.`name`,a.`name`");
$isBorrow=array();
while ($r = mysql_fetch_array($assets)){
		$isBorrow[]=array($r['id'],$r['name'],$r['count'],$r['notuse'],$r['stock'],$r['nametype'],$r['note'],$r['FullName'],$r['datetime'],$r['type'],$r['value'],$r['place']);
}



?>

<table cellpadding="0" cellspacing="1" border="0" class="ftable1" style="padding-left: 10px">
				           <tr>
				            	<th style="width: 30px"><?=$l_no?></th>
				            	<th style="width: 30px">
				            	<a onclick="deleteAssets(<?=count($isBorrow)?>)"><img src="images/del.png"  title="<?php echo $l_delete;?>" /></a>
								</th>
				                <th style="width: 170px"><?php echo $l_nameassets;?></th>
				                
				                <th style="width: 60px"><?php echo $l_total;?></th>
				                <th style="width: 60px"><?php echo $l_using;?></th>
				                <th style="width: 60px"><?php echo $l_notused;?></th>
				                <th style="width: 60px"><?php echo $l_stock;?></th>
				                <th style="width: 130px"><?php echo $l_value; ?></th>
                                <th style="width: 220px"><?php echo $l_place; ?></th>
				                <th style="width: 140px"><?php echo $l_note;?></th>
				                <th style="width: 20px"><?php echo $l_memo; ?></th>
				                <th style="width: 140px"><?php echo $l_author;?></th>
				                <th style="width: 140px"><?php echo $l_time;?></th>
				                <th style="width: 20px"><?php echo $l_move;?></th>
				            </tr>
				            <?php 
				            $i=0;
				            $temp="";
				            foreach ($isBorrow as $value => $giatri)
						    {
				            		if ($giatri[5]!=$temp){
				            			$result=mysql_query("SELECT SUM(a.count) as sumcount,SUM(a.notuse) as sumnotuse,SUM(a.stock) as sumstock FROM assets a WHERE a.type='".$giatri[9]."' AND a.`group`='".$_REQUEST['id']."';");
				            			$temp=	$giatri[5];
				            			$r=mysql_fetch_assoc($result);
				            			$tong=$r['sumcount']+$r['sumnotuse']+$r['sumstock'];
				            			echo '<tr>
				            					<td colspan="3" style="font-weight:bold;height:30px;text-align:left;padding-left:20px;background: #B1BBBB">'.$giatri[5].' ('.$tong.')</td>
				            					<td colspan="11" style="font-weight:bold;height:30px;text-align:left;padding-left:10px;background: #B1BBBB">'.$l_using.'('.$r['sumcount'].') - '.$l_notused.'('.$r['sumnotuse'].') - '.$l_stock.'('.$r['sumstock'].')</td>
				            			</tr>';
				            		}
				        
				            	
				            	?>
				            <tr>
				             
				            	<td><?=$i+1?></td>
				            	<td><?php //if($giatri[2]>0){?><input type="checkbox" name="<?php echo 'checkis'.$i?>" id="<?php echo 'checkis'.$i?>"  value="<?=$giatri[0]?>"><?php //}?></td>
				                <td style="padding-left: 5px;text-align: left;"><a onclick="checkonlyis('<?=$giatri[0]?>');" ><?php echo $giatri[1];?></a></td>
				                
				                <td style="font-weight: bold;background: #B0D9FF"><?php echo $giatri[2]+$giatri[3]+$giatri[4];?></td>
				                <td><?php echo $giatri[2];?></td>
				                <td style='background: #FF9999'><?php echo $giatri[3];?></td>
				                <td><?php echo $giatri[4];?></td>
				                
				                <td style="text-align: right;padding-right: 5px"><?php echo number_format($giatri[10]); ?></td>
                                <td style="text-align: left;padding-left: 5px"><?php echo $giatri[11]; ?></td>
                                                
                                <td style="text-align: left;padding-left: 5px"><?php echo $giatri[6]; ?></td>
                                <td><a onclick="showmemoAssets('<?= $giatri[0] ?>','<?= $giatri[1] ?>',this)"><img src="images/attibutes.png"  title="<?php echo $l_memo; ?>" /></a></td>
				                <td><?php echo $giatri[7];?></td>
				                <td><?php echo $giatri[8];?></td>
				                <td><a onclick="showmoveAssets('<?=$giatri[0]?>')"><img src="images/communication.png"  title="<?php echo $l_move;?>" /></a></td>
				            </tr>
				            <?php 
				            $i++; 
							}
				            if($i==0){
				            ?>
				            	 <tr><td colspan="14" style="height:30px;text-align:left;padding-left:20px;background: #D0D8E8"><?php echo $l_list_emplty;?></td></tr>
				            	 <?php }?>
			   </table>
<?php mysql_close($connection);?>			   